﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;

namespace StudentManagement
{
    public static class AppUtil
    {
        private const string TIPS = "提示";
        private const string WARNING = "警告";
        private const string ERROR = "错误";
        private const string CONFIRM = "确认";

        /// <summary>
        /// 弹出一个消息提示框
        /// </summary>
        public static void ShowInfoAlert(this string msg)
        {
            MessageBox.Show(msg, TIPS, MessageBoxButton.OK, MessageBoxImage.Information);
        }

        /// <summary>
        /// 弹出一个警告框
        /// </summary>
        /// <param name="msg"></param>
        public static void ShowWarningAlert(this string msg)
        {
            MessageBox.Show(msg, WARNING, MessageBoxButton.OK, MessageBoxImage.Warning);
        }


        /// <summary>
        /// 弹出一个错误框
        /// </summary>
        /// <param name="msg"></param>
        public static void ShowErrorAlert(this string msg)
        {
            MessageBox.Show(msg, ERROR, MessageBoxButton.OK, MessageBoxImage.Error);
        }

        /// <summary>
        /// 弹出一个确认框
        /// </summary>
        /// <param name="msg"></param>
        public static MessageBoxResult ShowConfirmAlert(this string msg)
        {
            return MessageBox.Show(msg, CONFIRM, MessageBoxButton.OKCancel, MessageBoxImage.Information);
        }

        /// <summary>
        /// 打开一个新的模态窗口并且不显示在任务栏中
        /// </summary>
        /// <param name="win"></param>
        /// <param name="owner"></param>
        /// <returns></returns>
        public static bool? ShowDialog(this Window win, Window owner)
        {
            win.Owner = owner;
            win.ShowInTaskbar = false;
            return win.ShowDialog();
        }
    }
}
